(function ($) {
    // Search Btn Active Code
    $('#user-btn, #closeBtn').on('click', function () {
        $(".fancy-user-form").toggleClass('user-form-on user-form-hide');

        if ($('.navbar-toggler').css('display') === 'block')
            $('.navbar-toggler').click()
    });

    $('#login-btn').on('click', function () {
        login($("input[name='login_username']").val(), $("input[name='login_password']").val());
    });

    $('#logon-btn').on('click', function () {
        window.location.href = '/user/logon.html';
    });

    // Sticky Active Code
    if ($.fn.sticky) {
        $("#header").sticky({
            topSpacing: 0
        });
    }

    $(document).ready(function () {
        //设置标题栏底色
        if ($(window).scrollTop() != 0)
            $("#header-sticky-wrapper").addClass("is-sticky");

        if ($.cookie('username') !== undefined)
            show_user_detail();

        $(".profile-title").html($.cookie('username'));
        $(".profile-photo-title").attr("src", $.cookie('profile-photo'));
        $(".profile-photo-title").click(function () {
            $("#profile-photo-upload").click();
        });
    })
})(jQuery);